// StringZabawa.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

void stringcpy(char *cel, char *zrodlo)
{
	int i = 0;
	for (i = 0; (*(zrodlo + i) != 0); i++)
	{
		*(cel + i) = *(zrodlo + i);
	}
	*(cel + i) = NULL;
}

void stringcpy2(char *cel, char *zrodlo)
{
	int i = 0;
	do	{
		*(cel + i) = *(zrodlo + i);
	}while (*(cel + i++) != 0);
}

void stringcpy3(char *cel, char *zrodlo)
{
	int i = 0;
	while ((cel[i]=zrodlo[i]))i++;
}

void stringinv(char *cel, char *zrodlo)
{
	int i = 0, j = 0;
	while (zrodlo[i])
		i++;
	while ((cel[j] = zrodlo[i]))
	{
		i--;
		j++;
	}
}

void revert(char* txt)
{
	char *t = txt + strlen(txt) - 1;
	char h;
	while (txt < t)
	{
		h = *txt;
		*txt = *t;
		*t = h;
		t--;
		txt++;
	}
}

void swap2(char* txt)
{
	int l = strlen(txt)-1;
	for (int i = 0; i < l; i++, l--)
		swap(txt[i], txt[l]);
}

int main()
{
	char tablica[] = ("zabawa");
	char docelowa[20] = { "miejsce na string" };
	puts(tablica);
	puts(docelowa);
	cout << strlen(tablica) << endl;

	swap2(tablica);

	puts(tablica);

	system("PAUSE");
	return 0;
}

